<?php
/**
 * api data xref table class
 * 
 * @package    jbookstore
 * @subpackage api * 
 * @license        GNU/GPL
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

/**
 * api_data_xref Table class
 * 
 * This table is a convenience for apis to share data;
 * consolidates data for management by multiple apis;
 * allow for more direct access of correlative data
 *
 * @package    Joomla.Tutorials
 * @subpackage Components
 */
class TableApi_data_xref extends JTable
{
    /**
     * Primary Key
     *
     * @var int
     */
    var $id = null;
    
    /**
     * id reference to native data
     * 
     * for author's purposes, native is bookstore component
     *
     * @var int
     */
    var $native_id = null;
    
    /**
     * id reference to cross referencing component's data
     *
     * @var int
     */
    var $xref_id = null;
    
    /**
     * option name for 'native' component
     * 
     * for author's purposes this is com_bookstore
     *
     * @var string varchar
     */
    var $native_com = null;
    
    /**
     * option name for cross referencing component
     * 
     * @var string varchar
     */
    var $xref_com = null;
    
    /**
     * parameters field
     *
     * @var string text data usually in ini form
     */
    var $params = '';
    
    /**
     * Constructor
     *
     * @param object Database connector object
     */
    function TableApi_data_xref( &$db ) {
        parent::__construct('#__api_data_xref', 'id', $db);
    }
    /**
     * Enter description here...
     *
     * @param array $data
     * @return unknown
     */
    function locateData($data){    	
    	$db =& $this->getDBO();  
    	foreach($data as $k=>$v){
    		if(!isset($where)){$where = ' WHERE ';}else{$where .=' AND ';}
    		$where .= $k.' = '.$db->Quote($v);
    	}
    	$query = "SELECT * FROM ".$this->_tbl.$where;
    	$db->setQuery( $query );
		$rows =& $db->loadObjectList();
    	return $rows;
    }
}
?>